Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow. New
authorAlexander Larsson <alexl@redhat.com>
Mon, 5 Mar 2001 15:09:02 +0000 (15:09 +0000)
committerAlexander Larsson <alexl@src.gnome.org>
Mon, 5 Mar 2001 15:09:02 +0000 (15:09 +0000)
2001-03-05  Alexander Larsson  <alexl@redhat.com>

* gdk/gdkwindow.h:
Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
gdk_window_set_icon_list for net wmspec functionality.

* gdk/x11/gdkwindow-x11.c:
Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
gdk_window_set_icon_list.
Added gdk_wmspec_change_state helper function and used it in the code.
Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.

* gtk/gtkdialog.c (gtk_dialog_init):
Set GDK_WINDOW_TYPE_HINT_DIALOG.

* gtk/gtkhandlebox.c (gtk_handle_box_realize):
Set GDK_WINDOW_TYPE_HINT_TOOLBAR.

* gtk/gtkwindow.c:
new function gtk_window_set_type_hint.
On realize, set type hint and modal hint.

* gtk/gtkwindow.h:
Added type_hint field and gtk_window_set_type_hint.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkwindow.h
gdk/x11/gdkwindow-x11.c
gtk/gtkdialog.c
gtk/gtkhandlebox.c
gtk/gtkwindow.c
gtk/gtkwindow.h

index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 45318a5b0183c1371687bee5d2957a73300abd7e..bbc1d02b3d46ab4e9be1bc65ee60c36a4129eaa7 100644 (file)
@@ -1,3 +1,30 @@
+2001-03-05  Alexander Larsson  <alexl@redhat.com>
+
+       * gdk/gdkwindow.h:
+       Added GdkWindowTypeHint type. Added modal_hint field to GdkWindindow.
+       New functions gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list for net wmspec functionality.
+
+       * gdk/x11/gdkwindow-x11.c:
+       Set _NEW_WM_STATE_MODAL from window->modal_hint in set_inital_hints.
+       Implement gdk_window_set_type_hint, gdk_window_set_modal_hint and
+       gdk_window_set_icon_list.
+       Added gdk_wmspec_change_state helper function and used it in the code.
+       Set _NET_WM_ICON_NAME in gdk_window_set_title and gdk_window_set_icon_name.
+
+       * gtk/gtkdialog.c (gtk_dialog_init):
+       Set GDK_WINDOW_TYPE_HINT_DIALOG.
+
+       * gtk/gtkhandlebox.c (gtk_handle_box_realize):
+       Set GDK_WINDOW_TYPE_HINT_TOOLBAR.
+
+       * gtk/gtkwindow.c:
+       new function gtk_window_set_type_hint.
+       On realize, set type hint and modal hint.
+
+       * gtk/gtkwindow.h:
+       Added type_hint field and gtk_window_set_type_hint.
+
 2001-03-05  Alexander Larsson  <alexl@redhat.com>
 
        * gtk/gtklabel.[ch]:
index 13d1aac25312d16a9e92f7ee4da95aba7fa88f44..4d0e22b54c7461f9c3652efc49682a88120b45a7 100644 (file)
@@ -84,6 +84,28 @@ typedef enum
   GDK_HINT_WIN_GRAVITY = 1 << 6
 } GdkWindowHints;
 
+
+/* Window type hints.
+ * These are hints for the window manager that indicate
+ * what type of function the window has. The window manager
+ * can use this when determining decoration and behaviour
+ * of the window. The hint must be set before mapping the
+ * window.
+ *
+ *   Normal: Normal toplevel window
+ *   Dialog: Dialog window
+ *   Menu: Window used to implement a menu.
+ *   Toolbar: Window used to implement toolbars.
+ */
+typedef enum
+{
+  GDK_WINDOW_TYPE_HINT_NORMAL,
+  GDK_WINDOW_TYPE_HINT_DIALOG,
+  GDK_WINDOW_TYPE_HINT_MENU,
+  GDK_WINDOW_TYPE_HINT_TOOLBAR
+} GdkWindowTypeHint;
+
+
 /* The next two enumeration values current match the
  * Motif constants. If this is changed, the implementation
  * of gdk_window_set_decorations/gdk_window_set_functions
@@ -204,6 +226,7 @@ struct _GdkWindowObject
   
   guint guffaw_gravity : 1;
   guint input_only : 1;
+  guint modal_hint : 1;
   
   guint destroyed : 2;
 };
@@ -332,6 +355,10 @@ void             gdk_window_set_hints       (GdkWindow       *window,
                                          gint             max_width,
                                          gint             max_height,
                                          gint             flags);
+void          gdk_window_set_type_hint   (GdkWindow       *window,
+                                         GdkWindowTypeHint hint);
+void          gdk_window_set_modal_hint  (GdkWindow       *window,
+                                         gboolean         modal);
 void          gdk_window_set_geometry_hints (GdkWindow        *window,
                                             GdkGeometry      *geometry,
                                             GdkWindowHints    flags);
@@ -389,6 +416,8 @@ GdkEventMask  gdk_window_get_events  (GdkWindow       *window);
 void         gdk_window_set_events      (GdkWindow       *window,
                                          GdkEventMask     event_mask);
 
+gboolean      gdk_window_set_icon_list   (GdkWindow       *window,
+                                         GList           *pixbufs);
 void         gdk_window_set_icon        (GdkWindow       *window, 
                                          GdkWindow       *icon_window,
                                          GdkPixmap       *pixmap,
index c59d43bdb9db7c404adee626cb9cdc060ccc66e6..9988235ae8e3ab9ea2029239dfda08b8ceba2974 100644 (file)
@@ -761,6 +761,12 @@ set_initial_hints (GdkWindow *window)
       ++i;
     }
 
+  if (private->modal_hint)
+    {
+      atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE);
+      ++i;
+    }
+
   if (i > 0)
     {
       XChangeProperty (GDK_WINDOW_XDISPLAY (window),
@@ -1141,6 +1147,121 @@ gdk_window_set_hints (GdkWindow *window,
                     &size_hints);
 }
 
+/**
+ * gdk_window_set_type_hint:
+ * @window: A #GdkWindow
+ * @hint: A hint of the function this window will have
+ *
+ * The application can use this call to provide a hint to the window
+ * manager about the functionality of a window. The window manager
+ * can use this information when determining the decoration and behaviour
+ * of the window.
+ *
+ * The hint must be set before the window is mapped.
+ **/
+void
+gdk_window_set_type_hint (GdkWindow        *window,
+                         GdkWindowTypeHint hint)
+{
+  GdkAtom atom;
+  
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  
+  if (GDK_WINDOW_DESTROYED (window))
+    return;
+
+  switch (hint)
+    {
+    case GDK_WINDOW_TYPE_HINT_DIALOG:
+      atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DIALOG", FALSE);
+      break;
+    case GDK_WINDOW_TYPE_HINT_MENU:
+      atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_MENU", FALSE);
+      break;
+    case GDK_WINDOW_TYPE_HINT_TOOLBAR:
+      atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_TOOLBAR", FALSE);
+      break;
+    default:
+      g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
+      /* Fall thru */
+    case GDK_WINDOW_TYPE_HINT_NORMAL:
+      atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_NORMAL", FALSE);
+      break;
+    }
+
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                  GDK_WINDOW_XID (window),
+                  gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
+                  XA_ATOM, 32, PropModeReplace,
+                  (guchar *)&atom, 1);
+}
+
+
+static void
+gdk_wmspec_change_state (gboolean add,
+                        GdkWindow *window,
+                        GdkAtom state1,
+                        GdkAtom state2)
+{
+  XEvent xev;
+  Atom op;
+
+  if (add)
+    op = gdk_atom_intern ("_NET_WM_STATE_ADD", FALSE);
+  else
+    op = gdk_atom_intern ("_NET_WM_STATE_REMOVE", FALSE);
+  
+  xev.xclient.type = ClientMessage;
+  xev.xclient.serial = 0;
+  xev.xclient.send_event = True;
+  xev.xclient.display = gdk_display;
+  xev.xclient.window = GDK_WINDOW_XID (window);
+  xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
+  xev.xclient.format = 32;
+  xev.xclient.data.l[0] = op;
+  xev.xclient.data.l[1] = state1;
+  xev.xclient.data.l[2] = state2;
+  
+  XSendEvent (gdk_display, gdk_root_window, False,
+             SubstructureRedirectMask | SubstructureNotifyMask,
+             &xev);
+}
+/**
+ * gdk_window_set_modal_hint:
+ * @window: A #GdkWindow
+ * @modal: TRUE if the window is modal, FALSE otherwise.
+ *
+ * The application can use this hint to tell the window manager
+ * that a certain window has modal behaviour. The window manager
+ * can use this information to handle modal windows in a special
+ * way.
+ *
+ * You should only use this on windows for which you have
+ * previously called #gdk_window_set_transient_for()
+ **/
+void
+gdk_window_set_modal_hint (GdkWindow *window,
+                          gboolean   modal)
+{
+  GdkWindowObject *private;
+
+  g_return_if_fail (window != NULL);
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  
+  if (GDK_WINDOW_DESTROYED (window))
+    return;
+
+  private = (GdkWindowObject*) window;
+
+  private->modal_hint = modal;
+
+  if (GDK_WINDOW_IS_MAPPED (window))
+    gdk_wmspec_change_state (modal, window,
+                            gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE),
+                            0);
+}
+
 void 
 gdk_window_set_geometry_hints (GdkWindow      *window,
                               GdkGeometry    *geometry,
@@ -1310,7 +1431,15 @@ gdk_window_set_title (GdkWindow   *window,
 
   set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title);
   if (!gdk_window_icon_name_set (window))
-    set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
+    {
+      XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                      GDK_WINDOW_XID (window),
+                      gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
+                      gdk_atom_intern ("UTF8_STRING", FALSE), 8,
+                      PropModeReplace, title,
+                      strlen (title));
+      set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title);
+    }
 }
 
 void          
@@ -1955,6 +2084,114 @@ gdk_window_set_override_redirect (GdkWindow *window,
     }
 }
 
+
+/**
+ * gdk_window_set_icon_list:
+ * @window: The #GdkWindow toplevel window to set the icon of.
+ * @pixbufs: A list of pixbufs, of different sizes.
+ * @Returns: TRUE if the icons were set, false otherwise
+ *
+ * Sets a list of icons for the window. One of these will be used
+ * to represent the window when it has been iconified. The icon is
+ * usually shown in an icon box or some sort of task bar. Which icon
+ * size is shown depends on the window manager. The window manager
+ * can scale the icon  but setting several size icons can give better
+ * image quality since the window manager may only need to scale the
+ * icon by a small amount or not at all.
+ *
+ * On the X11 backend this call might fail if the window manager
+ * doesn't support the Extended Window Manager Hints. Then this
+ * function returns FALSE, and the application should fall back
+ * to #gdk_window_set_icon().
+ **/
+gboolean
+gdk_window_set_icon_list (GdkWindow *window,
+                         GList     *pixbufs)
+{
+  guint *data;
+  guchar *pixels;
+  guint *p;
+  gint size;
+  GList *l;
+  GdkPixbuf *pixbuf;
+  gint width, height, stride;
+  gint x, y;
+  gint n_channels;
+  
+  g_return_val_if_fail (window != NULL, FALSE);
+  g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
+
+  if (GDK_WINDOW_DESTROYED (window))
+    return FALSE;
+
+  if (!gdk_net_wm_supports (gdk_atom_intern ("_NET_WM_ICON", FALSE)))
+    return FALSE;
+  
+  l = pixbufs;
+  size = 0;
+  
+  while (l)
+    {
+      pixbuf = l->data;
+      g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
+
+      width = gdk_pixbuf_get_width (pixbuf);
+      height = gdk_pixbuf_get_height (pixbuf);
+      
+      size += 2 + width * height;
+
+      l = g_list_next (l);
+    }
+
+  data = g_malloc (size*4);
+
+  l = pixbufs;
+  p = data;
+  while (l)
+    {
+      pixbuf = l->data;
+      
+      width = gdk_pixbuf_get_width (pixbuf);
+      height = gdk_pixbuf_get_height (pixbuf);
+      stride = gdk_pixbuf_get_rowstride (pixbuf);
+      n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+      
+      *p++ = width;
+      *p++ = height;
+
+      pixels = gdk_pixbuf_get_pixels (pixbuf);
+
+      for (y = 0; y < height; y++)
+       {
+         for (x = 0; x < width; x++)
+           {
+             guchar r, g, b, a;
+             
+             r = pixels[y*stride + x*n_channels + 0];
+             g = pixels[y*stride + x*n_channels + 1];
+             b = pixels[y*stride + x*n_channels + 2];
+             if (n_channels >= 4)
+               a = pixels[y*stride + x*n_channels + 3];
+             else
+               a = 255;
+             
+             *p++ = a << 24 | r << 16 | g << 8 | b ;
+           }
+       }
+
+      l = g_list_next (l);
+    }
+
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                  GDK_WINDOW_XID (window),
+                  gdk_atom_intern ("_NET_WM_ICON", FALSE),
+                  XA_CARDINAL, 32,
+                  PropModeReplace,
+                  (guchar*) data, size);
+
+  return TRUE;
+}
+
 void          
 gdk_window_set_icon (GdkWindow *window, 
                     GdkWindow *icon_window,
@@ -2017,6 +2254,12 @@ gdk_window_set_icon_name (GdkWindow   *window,
   g_object_set_qdata (G_OBJECT (window), g_quark_from_static_string ("gdk-icon-name-set"),
                      GUINT_TO_POINTER (TRUE));
 
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                  GDK_WINDOW_XID (window),
+                  gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE),
+                  gdk_atom_intern ("UTF8_STRING", FALSE), 8,
+                  PropModeReplace, name,
+                  strlen (name));
   set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name);
 }
 
@@ -2096,21 +2339,9 @@ gdk_window_stick (GdkWindow *window)
       XEvent xev;
 
       /* Request stick during viewport scroll */
-      xev.xclient.type = ClientMessage;
-      xev.xclient.serial = 0;
-      xev.xclient.send_event = True;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (window);
-      xev.xclient.display = gdk_display;
-      xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
-      xev.xclient.format = 32;
-
-      xev.xclient.data.l[0] = gdk_atom_intern ("_NET_WM_STATE_ADD", FALSE);
-      xev.xclient.data.l[1] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
-      xev.xclient.data.l[2] = 0;
-      
-      XSendEvent (gdk_display, gdk_root_window, False,
-                  SubstructureRedirectMask | SubstructureNotifyMask,
-                  &xev);
+      gdk_wmspec_change_state (TRUE, window,
+                              gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
+                              0);
 
       /* Request desktop 0xFFFFFFFF */
       xev.xclient.type = ClientMessage;
@@ -2154,21 +2385,9 @@ gdk_window_unstick (GdkWindow *window)
       gulong *current_desktop;
       
       /* Request unstick from viewport */
-      xev.xclient.type = ClientMessage;
-      xev.xclient.serial = 0;
-      xev.xclient.send_event = True;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (window);
-      xev.xclient.display = gdk_display;
-      xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
-      xev.xclient.format = 32;
-
-      xev.xclient.data.l[0] = gdk_atom_intern ("_NET_WM_STATE_REMOVE", FALSE);
-      xev.xclient.data.l[1] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE);
-      xev.xclient.data.l[2] = 0;
-      
-      XSendEvent (gdk_display, gdk_root_window, False,
-                  SubstructureRedirectMask | SubstructureNotifyMask,
-                  &xev);
+      gdk_wmspec_change_state (FALSE, window,
+                              gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE),
+                              0);
 
       /* Get current desktop, then set it; this is a race, but not
        * one that matters much in practice.
@@ -2217,31 +2436,13 @@ gdk_window_maximize (GdkWindow *window)
     return;
 
   if (GDK_WINDOW_IS_MAPPED (window))
-    {
-      XEvent xev;
-
-      xev.xclient.type = ClientMessage;
-      xev.xclient.serial = 0;
-      xev.xclient.send_event = True;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (window);
-      xev.xclient.display = gdk_display;
-      xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
-      xev.xclient.format = 32;
-
-      xev.xclient.data.l[0] = gdk_atom_intern ("_NET_WM_STATE_ADD", FALSE);
-      xev.xclient.data.l[1] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
-      xev.xclient.data.l[2] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
-      
-      XSendEvent (gdk_display, gdk_root_window, False,
-                  SubstructureRedirectMask | SubstructureNotifyMask,
-                  &xev);
-    }
+    gdk_wmspec_change_state (TRUE, window,
+                            gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
+                            gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
   else
-    {
-      gdk_synthesize_window_state (window,
-                                   0,
-                                   GDK_WINDOW_STATE_MAXIMIZED);
-    }
+    gdk_synthesize_window_state (window,
+                                0,
+                                GDK_WINDOW_STATE_MAXIMIZED);
 }
 
 void
@@ -2253,31 +2454,13 @@ gdk_window_unmaximize (GdkWindow *window)
     return;
 
   if (GDK_WINDOW_IS_MAPPED (window))
-    {
-      XEvent xev;
-
-      xev.xclient.type = ClientMessage;
-      xev.xclient.serial = 0;
-      xev.xclient.send_event = True;
-      xev.xclient.window = GDK_WINDOW_XWINDOW (window);
-      xev.xclient.display = gdk_display;
-      xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE);
-      xev.xclient.format = 32;
-
-      xev.xclient.data.l[0] = gdk_atom_intern ("_NET_WM_STATE_REMOVE", FALSE);
-      xev.xclient.data.l[1] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE);
-      xev.xclient.data.l[2] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE);
-      
-      XSendEvent (gdk_display, gdk_root_window, False,
-                  SubstructureRedirectMask | SubstructureNotifyMask,
-                  &xev);
-    }
+    gdk_wmspec_change_state (FALSE, window,
+                            gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE),
+                            gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE));
   else
-    {
-      gdk_synthesize_window_state (window,
-                                   GDK_WINDOW_STATE_MAXIMIZED,
-                                   0);
-    }
+    gdk_synthesize_window_state (window,
+                                GDK_WINDOW_STATE_MAXIMIZED,
+                                0);
 }
 
 void          
index cdacccaf490469be1006adc719aa2f05374489c1..85c3432bcd5684f826af3bbdf358994117fbaf2e 100644 (file)
@@ -139,6 +139,9 @@ gtk_dialog_init (GtkDialog *dialog)
   separator = gtk_hseparator_new ();
   gtk_box_pack_end (GTK_BOX (dialog->vbox), separator, FALSE, TRUE, 0);
   gtk_widget_show (separator);
+
+  gtk_window_set_type_hint (GTK_WINDOW (dialog),
+                           GDK_WINDOW_TYPE_HINT_DIALOG);
 }
 
 static gint
@@ -202,7 +205,7 @@ gtk_dialog_new_empty (const gchar     *title,
 
   if (flags & GTK_DIALOG_MODAL)
     gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-
+  
   if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
     gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
 
index ca2dd0321f081e4a40a4ef64a0d07037794c1fce..d9095f9f2047936f0bb75940d5fda7e27d6d18e0 100644 (file)
@@ -409,6 +409,7 @@ gtk_handle_box_realize (GtkWidget *widget)
   hb->float_window = gdk_window_new (NULL, &attributes, attributes_mask);
   gdk_window_set_user_data (hb->float_window, widget);
   gdk_window_set_decorations (hb->float_window, 0);
+  gdk_window_set_type_hint (hb->float_window, GDK_WINDOW_TYPE_HINT_TOOLBAR);
   
   widget->style = gtk_style_attach (widget->style, widget->window);
   gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (hb));
index 5324d0b0789f52320d016dd61aa969a601e1e864..3d632f5fa259ff0cbc9323a9f558b59848945a52 100644 (file)
@@ -314,6 +314,7 @@ gtk_window_init (GtkWindow *window)
   window->frame_right = 0;
   window->frame_top = 0;
   window->frame_bottom = 0;
+  window->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
     
   gtk_widget_ref (GTK_WIDGET (window));
   gtk_object_sink (GTK_OBJECT (window));
@@ -973,6 +974,30 @@ gtk_window_set_transient_for  (GtkWindow *window,
     }
 }
 
+/**
+ * gtk_window_set_type_hint:
+ * @window: a #GtkWindow
+ * @hint: the window type
+ *
+ * By setting the type hint for the window, you allow the window
+ * manager to decorate and handle the window in a way which is
+ * suitable to the function of the window in your application.
+ *
+ * This function should be called before the window becomes visible.
+ *
+ * gtk_dialog_new_with_buttons() and other convenience functions in GTK+
+ * will sometimes call gtk_window_set_type_hint() on your behalf.
+ * 
+ **/
+void
+gtk_window_set_type_hint (GtkWindow           *window, 
+                         GdkWindowTypeHint    hint)
+{
+  g_return_if_fail (GTK_IS_WINDOW (window));
+  g_return_if_fail (!GTK_WIDGET_VISIBLE (window));
+  window->type_hint = hint;
+}
+
 /**
  * gtk_window_set_destroy_with_parent:
  * @window: a #GtkWindow
@@ -1428,6 +1453,14 @@ gtk_window_realize (GtkWidget *widget)
       GTK_WIDGET_REALIZED (window->transient_parent))
     gdk_window_set_transient_for (widget->window,
                                  GTK_WIDGET (window->transient_parent)->window);
+
+  gdk_window_set_type_hint (widget->window, window->type_hint);
+
+  /* transient_for must be set to allow the modal hint */
+  if (window->transient_parent && window->modal)
+    gdk_window_set_modal_hint (widget->window, TRUE);
+  else
+    gdk_window_set_modal_hint (widget->window, FALSE);
 }
 
 static void
index 51be63fca83bc9338d5e45a237196af0b66a254f..92d97a3e4ba582944f6715ece74cd2f635125613 100644 (file)
@@ -89,7 +89,9 @@ struct _GtkWindow
   guint iconify_initially : 1;
   guint stick_initially : 1;
   guint maximize_initially : 1;
-  
+
+  GdkWindowTypeHint type_hint : 2;
+
   guint frame_left;
   guint frame_top;
   guint frame_right;
@@ -129,6 +131,8 @@ gint           gtk_window_activate_default         (GtkWindow           *window);
 
 void       gtk_window_set_transient_for        (GtkWindow           *window, 
                                                GtkWindow           *parent);
+void       gtk_window_set_type_hint            (GtkWindow           *window, 
+                                               GdkWindowTypeHint    hint);
 void       gtk_window_set_destroy_with_parent  (GtkWindow           *window,
                                                 gboolean             setting);
 void       gtk_window_set_geometry_hints       (GtkWindow           *window,